package app

import (
	"chatgpt/controller/father"
	"chatgpt/helper"
	"chatgpt/helper/code"
	"chatgpt/services"
	"chatgpt/services/datasrv/sqlhelper"
	"github.com/gin-gonic/gin"
)

// 商品列表
func ProductListHandle(ctx *gin.Context) {
	procs := services.ProductSrv.GetList("", 0, 100)
	total := services.ProductSrv.TotalDB(&sqlhelper.Where{
		Conds: []*sqlhelper.CondItem{
			sqlhelper.WhereCond("Grounding", helper.GROUNDING_AT_1),
			sqlhelper.WhereCond("DeletedAt", 0),
		},
	})
	helper.Count(ctx, code.SUCCESS, map[string]any{
		"List":   procs,
		"Offset": 0,
		"Limit":  100,
		"Total":  total,
	})
}

// 商品详情页面
func ProductShowHandle(ctx *gin.Context) {
	proc_id := father.RawString(ctx, "ProcID")
	proc := services.ProductSrv.First(proc_id)

	helper.Count(ctx, code.SUCCESS, map[string]any{
		"Proc": proc,
		"Ads":  []string{},
	})
}
